home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / sharew / accs / print_db / etikette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-07-19  |  4.3 KB  |  135 lines

  1.  
  2. #include <stdio.h>
  3. #include <gemdefs.h>
  4. #include <osbind.h>
  5.  
  6. #define Cprnout(a)      gemdos(0x5,a)    /* Schickt  ein Zeichens an Drucker */
  7. #define prt_ready()     gemdos(0x11)     /* Prüft ob Drucker bereit ist  */
  8.  
  9. int ap_id;
  10. int menu_id;
  11.  
  12. extern int gl_apid;
  13.  
  14.  
  15.    pruefe_drucker()
  16.    {
  17.       while (!prt_ready())
  18.           form_alert(1,"[3][Schalten Sie den Drucker ON LINE! ][OK]");
  19.    }  
  20.  
  21.  
  22.    vorschub()
  23.    {               /* Erzeugt einen doppelten Zeilenvorschub */
  24.       Cprnout(13);    
  25.       Cprnout(10);
  26.       Cprnout(13);    
  27.       Cprnout(10);
  28.    } 
  29.    
  30.  
  31.  
  32.   drucke_etiketten()
  33.   {
  34.    int merke_blank,c,i,
  35.        st_vorname = 1,
  36.        st_strasse = 1,
  37.        st_plz     = 1,
  38.        st_wohnort = 1;
  39.    int pressed_button;        
  40.    
  41.    FILE *fopen(), *fp;
  42.    
  43.    if ((fp = fopen("ADRESSEN.RPT","r")) == NULL) /* existiert die Datei? */
  44.     form_alert(1,"[3][Ich kann die Datei ADRESSEN.RPT nicht finden][OK]");    
  45.    else
  46.    { 
  47.      pressed_button=form_alert(1,"[1][Drucker vorbereiten][weiter|Abbruch]");
  48.  
  49.      if (pressed_button == 1 )    /* Benutzer hat "weiter" angeklickt    */
  50.      {
  51.       pruefe_drucker();           /* Ist Drucker wirklich bereit?        */
  52.  
  53.       /* Suche anhand der Reporttitelzeile nach den Spalten in denen     */
  54.       /* Vorname, Straße und PLZ beginnen:                               */
  55.  
  56.       while ((( c = getc(fp)) != EOF) && (c != 10 )); /* Skip first Line  */
  57.       while ((( c = getc(fp)) != EOF) && (c <= 32 )); /* Skip Blanks&CRTS */
  58.                         /* lese bis zum Doppelpunkt:       */
  59.       while ((( c = getc(fp)) != EOF) && (c != 58 )) st_vorname++;
  60.                         /* Überlese nachfolgende Blanks:   */
  61.       while ((( c = getc(fp)) != EOF) && (c <= 32 )) st_vorname++;   
  62.       st_strasse = st_vorname;
  63.                         /* Suche ebenso die Spalten fuer Straße und PLZ */
  64.       while ((( c = getc(fp)) != EOF) && (c != 58 )) st_strasse++;
  65.       while ((( c = getc(fp)) != EOF) && (c <= 32 )) st_strasse++;
  66.       st_plz = st_strasse;
  67.       while ((( c = getc(fp)) != EOF) && (c != 58 )) st_plz++;
  68.       while ((( c = getc(fp)) != EOF) && (c <= 32 )) st_plz++;
  69.       st_wohnort = st_plz;
  70.       while ((( c = getc(fp)) != EOF) && (c != 58 )) st_wohnort++;
  71.       while ((( c = getc(fp)) != EOF) && (c <= 32 )) st_wohnort++;
  72.  
  73.       while ((( c = getc(fp)) != EOF) && (c != 10) ); /* skip bis Zeilenende */
  74.       while (c != EOF)
  75.       {
  76.            
  77.         while ((( c = getc(fp)) != EOF) && (c <= 32 )); /* Skip Blanks&CRTS */
  78.              
  79.                         /* Drucke Name und Vorname durch höchstens */
  80.                         /* ein Leerzeichen getrennt:               */ 
  81.         if (c >32) Cprnout(c);
  82.         i = 0;
  83.         merke_blank=c; 
  84.         while (((c = getc(fp)) !=EOF) && ( i++ <= st_strasse ) )
  85.         {
  86.             if((merke_blank == 32) && (c == 32));
  87.             else  Cprnout(c);            
  88.             merke_blank = c;
  89.         } 
  90.         Cprnout(c);
  91.       
  92.         vorschub();
  93.  
  94.                        /* Drucke Straße : */
  95.  
  96.         while (((c = getc(fp)) !=EOF)&& (i++ <= st_plz)  ) Cprnout(c);
  97.         Cprnout(c);
  98.  
  99.         vorschub();    
  100.                        /* Drucke PLZ und Wohnort:  */ 
  101.  
  102.         while ((( c = getc(fp)) != EOF) && (c <= 32 ));
  103.         Cprnout(c);
  104.         while ((( c = getc(fp)) != EOF) && (c != 10) ) Cprnout(c);
  105.             
  106.         vorschub();                 
  107.        }
  108.       }
  109.     }
  110.   }   /* drucke_etiketten*/
  111.  
  112.  
  113. main()
  114. {
  115.     int Mitteilung[8];
  116.     
  117.     ap_id = appl_init();        /* Mache das Programm dem AES bekannt */ 
  118.  
  119.     menu_id = menu_register(gl_apid, "  Etiketten");  
  120.                                 /* Erzeuge Eintrag im DESK Menu       */ 
  121.  
  122.     while(1==1)                 /* fuer immer:                        */
  123.     {
  124.       evnt_mesag(Mitteilung);   /* Warte auf Mitteilung vom AES       */      
  125.  
  126.       wind_update(BEG_UPDATE);  /* Bildschirm sperren                 */
  127.  
  128.       if(Mitteilung[0]==AC_OPEN && Mitteilung[4]==menu_id)  /* falls  */  
  129.             drucke_etiketten(); /* das Accessory angeklickt wurde:    */ 
  130.                                 /* starte Druckprogramm               */
  131.  
  132.       wind_update(END_UPDATE); /* Bildschirm freigeben                */    
  133.     }
  134. }    /* main */
  135.